/*======================================================================*\
|| #################################################################### ||
|| # Copyright ©2010-2013 Vu Thanh Lai. All Rights Reserved.          # ||
|| # Please do not remove this comment lines.                         # ||
|| #################################################################### ||
\*======================================================================*/
function balloonPopup(){
	this.playDuration=10; //In second
	this.innerWidth=445; //In pixel
	this.innerHeight=86; //In Pixel
	this.marginTop=-10; //In Pixel
	this.isDown=0;
	this.cookieName='closeBalloonPopup';
	this.closePopup=function(){
		var thisObj=this;
		if(this.isDown)
		{
			jQuery('#balloonPopupWrapper').fadeOut('fast',function(){
				jQuery(this).remove();
				document.cookie=thisObj.cookieName+'=1;path=/';
			});
			return true;
		}
		var h=jQuery(window).height();
		var curTop=jQuery(window).height()-jQuery('#balloonPopupWrapper').height();
		jQuery('#balloonPopupWrapper').css('top',curTop+'px');
		jQuery('#balloonPopupWrapper').css('bottom','auto');
		jQuery('#balloonPopupWrapper').animate({'top':h},'fast',function(){
			jQuery(this).remove();
			document.cookie=thisObj.cookieName+'=1;path=/';
		});
	}
	this.downPopup=function(){
		if(this.isDown)
			return false;
		var thisObj=this;
		var newTop=jQuery(window).height()-38;
		var curTop=jQuery(window).height()-jQuery('#balloonPopupWrapper').height();
		jQuery('#balloonPopupWrapper').css('top',curTop+'px');
		jQuery('#balloonPopupWrapper').css('bottom','auto');
		jQuery('#balloonPopupWrapper').animate({'top':newTop},'fast',function(){
			jQuery('#balloonPopupHead').fadeIn('fast');
			jQuery('#balloonControl').fadeOut('fast');
			thisObj.isDown=1;
		});
		
	}
	this.restorePopup=function(){
		var thisObj=this;
		jQuery('#balloonPopupHead').fadeOut('fast',function(){
			var newTop=jQuery(window).height()-jQuery('#balloonPopupWrapper').height();
			jQuery('#balloonPopupWrapper').animate({'top':newTop},'fast',function(){
				jQuery('#balloonControl').fadeIn('fast');
				thisObj.isDown=0;
			});
		});
	}
	this.showPopup=function(){
		if(document.cookie.indexOf(this.cookieName)!=-1)
			return false;
		var thisObj=this;
		if(jQuery('#vtlaiBalloonPopup').length==0)
		{
			jQuery('body').append('<div id="balloonPopupWrapper" style="position: fixed; right: 0px;bottom: 0px; border: 1px solid #4B4F55;z-index:10;">\
				<h4 id="balloonPopupHead" style="-webkit-box-sizing: border-box;-webkit-margin-before: 0;-webkit-margin-after: 0;-webkit-margin-start: 0;-webkit-margin-end: 0;-webkit-padding-start: 0;-webkit-padding-end: 0;padding:10px;margin:0;color: #F8F8FF;display: none;background-color: #4B4F55;font-size: 14px;font-family: Arial,Tahoma,San-serif;"><span class="restoreBalloonPopup" style="cursor: pointer;">SO YOU THINK YOU CAN SPEAK ENGLISH</span><a class="closeBalloonPopup" style="color: #FFF;text-decoration: none;float:right;margin:0;">X</a><a class="restoreBalloonPopup" style="color: #FFF;text-decoration: none;float:right;margin:0;margin-right: 10px;margin-top: -2px;">↑</a></h4>\
				<div style="display: block;background-color:#FFF;width:'+this.innerWidth+'px;height:'+this.innerHeight+'px;">\
					<div id="balloonControl" style="position: absolute;right: 0px;top:0px;"><a id="pushDownBalloonPopup" style="cursor: pointer;background:url(images/vtlai_balloonpopup.png) -8px -4px no-repeat;width: 30px;height: 30px; display: inline-block;"></a><a id="closeBalloonPopup" style="cursor: pointer;background:url(images/vtlai_balloonpopup.png) -10px -73px no-repeat;width: 30px;height: 30px; display: inline-block;"></a></div>\
					<!-- Ad by UniAd.Vn -->\
					<embed height="86" width="445" type="application/x-shockwave-flash" wmode="transparent" allowfullscreen="false" scale="noborder" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" quality="low" src="http://data.svnhforum.com/swf/445lang.swf"/>\
					<!-- /Ad by UniAd.Vn -->\
				</div>\
			</div>');
			jQuery('.closeBalloonPopup,#closeBalloonPopup').click(function(){
				thisObj.closePopup();
			});
			jQuery('#pushDownBalloonPopup').click(function(){
				thisObj.downPopup();
			});
			jQuery('.restoreBalloonPopup').click(function(){
				thisObj.restorePopup();
			});
		}
	}
};
var vtlaiBalloon=new balloonPopup();
function closeBalloonPopup()
{
	vtlaiBalloon.downPopup();
}
jQuery(document).ready(function(){
	vtlaiBalloon.showPopup();
	setTimeout('closeBalloonPopup()',10000);
});